package com.ruoyi.order.domain.ex;


public class OrderException extends RuntimeException {
    private Integer code;
    private Object data;


    public Integer getCode() {
        return code;
    }

    public OrderException(String message) {
        super(message);
    }

    public OrderException(Integer orderConstant, Object data) {
        this.code = orderConstant;
        this.data = data;
    }
    public OrderException(Integer orderConstant) {
        this.code = orderConstant;
    }

    public Object getData() {
        return data;
    }

    public String getMessage() {
        switch (code) {
            case OrderConstant.ORDER_UNPAID:
                return "当前存在未支付订单，暂时无法下单，你可以取消之前未支付的订单（确认后跳转未支付界面）";
            case OrderConstant.VEHICLE_RENT:
                return "该订单的车辆已被租用";
            case OrderConstant.ORDER_HAS_EXPIR:
                return "该订单已过期";
            case OrderConstant.ILLEGAL_AMOUNT:
                return "非法金额";
            case OrderConstant.ILLEGAL_TIME:
                return "非法时间";
            case OrderConstant.PAYMENT_SIGNATURE_ERROR:
                return "支付签名错误";
            case OrderConstant.ORDER_HAS_ROBBED:
                return "已被抢单";
            case OrderConstant.ILLEGAL_ACCESS:
                return "非法访问";
        }
        return super.getMessage();
    }
}

